import requests
# 这里是TPshop登录的接口封装不涉及到断言
# 业务逻辑层

class LoginAPI:
    def __init__(self):
        # 定义验证接口url地址
        self.url_verify = "http://localhost/index.php?m=Home&c=User&a=verify"
        # 定义登录接口url地址
        self.url_login = "http://localhost/index.php?m=Home&c=User&a=login"

    def get_verify_code(self):
        return self.session.get(self.url_verify)

    def login(self, username, password, verify_code="1234"):
        login_data = {"username": username,
                      "password": password,
                      "verify_code": verify_code
                      }
        return requests.post(self.url_login, json=login_data)